<template>
  <div class="talk">
    <button @click=" talkStore.getATalk()">获取一句土味情话</button>
    <ul>
      <li v-for="talk in talkStore.talkList" :key="talk.id">
        {{ talk.title }}
      </li>
    </ul>
  </div>
</template>

<script setup name = "LoveTalk" lang="ts">
import {reactive} from 'vue'
import axios from 'axios' // 是默认暴露的
import  {nanoid} from 'nanoid'
import { useTalkStore } from '@/store/loveTalks'
//------------------数据-------------------

const talkStore = useTalkStore()


talkStore.$subscribe((mutate, state)=>{
  console.log("看看你的");
  //直接写到本里里面 也就是刷新不丢失
  localStorage.setItem('talkList', JSON.stringify(state.talkList))
})



</script>

<style scoped>

.talk {
  background-color: orange;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 0 10px;
}

</style>